package org.starlight.user.serivce.impl;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.starlight.delete.DeleteRecordHelper;
import org.starlight.delete.enums.TableEnum;
import org.starlight.user.mapper.UsersMapper;
import org.starlight.user.entity.Users;
import org.starlight.user.repository.UsersRepository;
import org.starlight.user.serivce.UserService;

/**
 * @author huangyong
 * @data 2025/2/28
 */
@Service
@RequiredArgsConstructor
public class UserServiceImpl implements UserService {
    private final UsersMapper userMapper;
    private final UsersRepository usersRepository;

    @Override
    public void saveUser(Users users) {
        usersRepository.save(users);
    }

    @Override
    public void deleteUser(Integer id) {
        DeleteRecordHelper.saveDeleteRecord(TableEnum.users, usersRepository.findById(id).orElse(null));
        usersRepository.deleteById(id);
    }
}
